When you want to define a dynagroup, you can either type in the expression yourself or compose them via the wizard. A third alternative for common cases is to use canned expressions:
Unfortunately those expressions are hard coded in the server(1) and can't easily be added to by 3rd parties
1) Technically speaking in org.rhq.coregui.client.inventory.groups.definitions.SingleGroupDefinitionView#getTemplates
Proposal
We should put the definitions into the plugins so that plugin developers can define standard canned expressions, which can then be displayed in the servers list of expressions.
Server side storage
We could store the expressions in the database in a separate table (possibly just the whole JSON string in a clob). Deploying a new plugin would add new templates, update existing and remove ones that are no longer in the plugin. As alternative we could also leave them in the plugins and dynamically populate the dropdown / list of templates from the plugins when the user wants to create a new DynaGroup. This is possible as we do not relationally refer to the templates, but copy their content when the user selects one.
UI handling
As the list could grow large with many plugins, we should think of allowing to filter entries
As we already have the DynaGroup-Wizard and the input field to write such expressions, a user with INVENTORY_MANAGER could get additional buttons and fields to store such an expression and also remove user generated expressions. The user generated expressions could get a "plugin name" of "User" (or " User" to sort them in the list to the top). or similar. Also we must make sure that the canned expressions will now show the delete button.
Agent side handling
Agents do not need access to the dynagroup expressions, so they do not need to touch or parse that descriptor
Lifecycle on the server
When a plugin is parsed on the server, the canned expressions are just added to the list of available expressions if they are not yet there. If they already exist, they are replaced. Expressions for a plugin that are no longer provided by the plugin are deleted.
When a plugin is deleted (removed, purged, killed) the expressions of it are removed - especially as killing a plugin also removes all its resource types and resources of that type.
User defined expressions just stay until the user cleans them up.
Questions:
-
Should the user be allowed to define such canned expressions on his own: YES
-
If yes: how can an end user define entries on his own? One possibility could be to write an empty plugin that just holds those values.
-
Use some additional UI elements to save / delete what the user has provided in the textfield
-
Should a template with deployByDefault=true be deleted on plugin undelete? If the resources defined by the plugin are gone, the expression is probably no longer needed: YES
-
Should a template with deployByDefault=true be hidden from the user? I think the user may still want to use that as a template for his own trials, so we should offer it, but without any automatic recalculations